<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Compound Attribute Rules</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Spirit 2.5.8">
<link rel="up" href="../quick_reference.html" title="Quick Reference">
<link rel="prev" href="primitive_generators/action.html" title="Generator Semantic Actions">
<link rel="next" href="non_terminals.html" title="Nonterminals">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="primitive_generators/action.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../quick_reference.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="non_terminals.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="spirit.karma.quick_reference.compound_attribute_rules"></a><a class="link" href="compound_attribute_rules.html" title="Compound Attribute Rules">Compound
        Attribute Rules</a>
</h4></div></div></div>
<h6>
<a name="spirit.karma.quick_reference.compound_attribute_rules.h0"></a>
          <span class="phrase"><a name="spirit.karma.quick_reference.compound_attribute_rules.notation"></a></span><a class="link" href="compound_attribute_rules.html#spirit.karma.quick_reference.compound_attribute_rules.notation">Notation</a>
        </h6>
<p>
          The notation we use is of the form:
        </p>
<pre class="programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">B</span><span class="special">,</span> <span class="special">...</span> <span class="special">--&gt;</span> <span class="identifier">composite</span><span class="special">-</span><span class="identifier">expression</span><span class="special">:</span> <span class="identifier">composite</span><span class="special">-</span><span class="identifier">attribute</span>
</pre>
<p>
          <code class="computeroutput"><span class="identifier">a</span></code>, <code class="computeroutput"><span class="identifier">b</span></code>,
          etc. are the operands. <code class="computeroutput"><span class="identifier">A</span></code>,
          <code class="computeroutput"><span class="identifier">B</span></code>, etc. are the operand's
          attribute types. <code class="computeroutput"><span class="identifier">composite</span><span class="special">-</span><span class="identifier">expression</span></code>
          is the expression involving the operands and <code class="computeroutput"><span class="identifier">composite</span><span class="special">-</span><span class="identifier">attribute</span></code>
          is the resulting attribute type of the composite expression.
        </p>
<p>
          For instance:
        </p>
<pre class="programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">B</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">&lt;&lt;</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">tuple</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">&gt;</span>
</pre>
<p>
          which reads as: given, <code class="computeroutput"><span class="identifier">a</span></code>
          and <code class="computeroutput"><span class="identifier">b</span></code> are generators, and
          <code class="computeroutput"><span class="identifier">A</span></code> is the type of the attribute
          of <code class="computeroutput"><span class="identifier">a</span></code>, and <code class="computeroutput"><span class="identifier">B</span></code> is the type of the attribute of <code class="computeroutput"><span class="identifier">b</span></code>, then the type of the attribute of
          <code class="computeroutput"><span class="identifier">a</span> <span class="special">&lt;&lt;</span>
          <span class="identifier">b</span></code> will be <code class="computeroutput"><span class="identifier">tuple</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">&gt;</span></code>.
        </p>
<div class="important"><table border="0" summary="Important">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../images/important.png"></td>
<th align="left">Important</th>
</tr>
<tr><td align="left" valign="top"><p>
            In the attribute tables, we will use <code class="computeroutput"><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span></code> and <code class="computeroutput"><span class="identifier">tuple</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">...&gt;</span></code> as placeholders only. The notation
            of <code class="computeroutput"><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span></code>
            stands for <span class="emphasis"><em>any <a href="https://en.wikipedia.org/wiki/Standard_Template_Library" target="_top">STL</a>
            container</em></span> holding elements of type <code class="computeroutput"><span class="identifier">A</span></code>
            and the notation <code class="computeroutput"><span class="identifier">tuple</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">...&gt;</span></code> stands for <span class="emphasis"><em>any <a href="../../../../../../../libs/fusion/doc/html/index.html" target="_top">Boost.Fusion</a> sequence</em></span>
            holding <code class="computeroutput"><span class="identifier">A</span></code>, <code class="computeroutput"><span class="identifier">B</span></code>, ... etc. elements. The notation
            of <code class="computeroutput"><span class="identifier">variant</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">,</span> <span class="special">...&gt;</span></code> stands for <span class="emphasis"><em>a <a href="http://www.boost.org/doc/html/variant.html" target="_top">Boost.Variant</a></em></span>
            capable of holding <code class="computeroutput"><span class="identifier">A</span></code>,
            <code class="computeroutput"><span class="identifier">B</span></code>, ... etc. elements.
            Finally, <code class="computeroutput"><span class="identifier">Unused</span></code> stands
            for <code class="computeroutput"><span class="identifier">unused_type</span></code>.
          </p></td></tr>
</table></div>
<h6>
<a name="spirit.karma.quick_reference.compound_attribute_rules.h1"></a>
          <span class="phrase"><a name="spirit.karma.quick_reference.compound_attribute_rules.compound_generator_attribute_types"></a></span><a class="link" href="compound_attribute_rules.html#spirit.karma.quick_reference.compound_attribute_rules.compound_generator_attribute_types">Compound
          Generator Attribute Types</a>
        </h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Expression
                  </p>
                </th>
<th>
                  <p>
                    Attribute
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
                    <a class="link" href="../reference/operator/sequence.html" title="Sequence Generator (a &lt;&lt; b)">Sequence
                    (<code class="computeroutput"><span class="special">&lt;&lt;</span></code>)</a>
                    (<code class="computeroutput"><span class="identifier">a</span> <span class="special">&lt;&lt;</span>
                    <span class="identifier">b</span></code>)
                  </p>
                </td>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">B</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">&lt;&lt;</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">tuple</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">&gt;</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">&lt;&lt;</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">A</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">B</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">&lt;&lt;</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">B</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">&lt;&lt;</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">Unused</span>

<span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">A</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">&lt;&lt;</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">A</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">&lt;&lt;</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">&lt;&lt;</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">&lt;&lt;</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span></pre>
<p>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <a class="link" href="../reference/operator/alternative.html" title="Alternative Generator (a | b)">Alternative
                    (<code class="computeroutput"><span class="special">|</span></code>)</a> (<code class="computeroutput"><span class="identifier">a</span> <span class="special">|</span>
                    <span class="identifier">b</span></code>)
                  </p>
                </td>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">B</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">|</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">variant</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">&gt;</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">|</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">A</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">B</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">|</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">B</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">|</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">Unused</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">A</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">|</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">A</span></pre>
<p>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <a class="link" href="../reference/operator/kleene.html" title="Kleene Star Generator (*a)">Kleene
                    (<code class="computeroutput"><span class="special">*</span><span class="identifier">a</span></code>)</a>
                  </p>
                </td>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span> <span class="special">--&gt;</span> <span class="special">*</span><span class="identifier">a</span><span class="special">:</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--&gt;</span> <span class="special">*</span><span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span></pre>
<p>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <a class="link" href="../reference/operator/plus.html" title="Plus Generator (+a)">Plus (unary
                    <code class="computeroutput"><span class="special">+</span></code>)</a> (<code class="computeroutput"><span class="special">+</span><span class="identifier">a</span></code>)
                  </p>
                </td>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span> <span class="special">--&gt;</span> <span class="special">+</span><span class="identifier">a</span><span class="special">:</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--&gt;</span> <span class="special">+</span><span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span></pre>
<p>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <a class="link" href="../reference/operator/list.html" title="List Generator (a % b)">List (<code class="computeroutput"><span class="special">%</span></code>)</a> (<code class="computeroutput"><span class="identifier">a</span>
                    <span class="special">%</span> <span class="identifier">b</span></code>)
                  </p>
                </td>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">B</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">%</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span><span class="special">,</span> <span class="identifier">b</span><span class="special">:</span> <span class="identifier">B</span> <span class="special">--&gt;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">%</span> <span class="identifier">b</span><span class="special">):</span> <span class="identifier">Unused</span></pre>
<p>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <a class="link" href="../reference/directive/repeat.html" title="Repetition Generator Directive (repeat[])">Repetition</a>
                    (<code class="computeroutput"><span class="identifier">repeat</span><span class="special">[]</span></code>)
                  </p>
                </td>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span> <span class="special">--&gt;</span> <span class="identifier">repeat</span><span class="special">(...,...)[</span><span class="identifier">a</span><span class="special">]:</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--&gt;</span> <span class="identifier">repeat</span><span class="special">(...,...)[</span><span class="identifier">a</span><span class="special">]:</span> <span class="identifier">Unused</span></pre>
<p>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <a class="link" href="../reference/operator/optional.html" title="Optional Generator (-a)">Optional
                    (unary <code class="computeroutput"><span class="special">-</span></code>)</a>
                    (<code class="computeroutput"><span class="special">-</span><span class="identifier">a</span></code>)
                  </p>
                </td>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span> <span class="special">--&gt;</span> <span class="special">-</span><span class="identifier">a</span><span class="special">:</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span>
<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--&gt;</span> <span class="special">-</span><span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span></pre>
<p>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <a class="link" href="../reference/operator/and_predicate.html" title="And-Predicate Generator (&amp;a)">And
                    predicate (unary <code class="computeroutput"><span class="special">&amp;</span></code>)</a>
                    (<code class="computeroutput"><span class="special">&amp;</span><span class="identifier">a</span></code>)
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">a</span><span class="special">:</span>
                    <span class="identifier">A</span> <span class="special">--&gt;</span>
                    <span class="special">&amp;</span><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span></code>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <a class="link" href="../reference/operator/not_predicate.html" title="Not-Predicate Generator (!a)">Not
                    predicate (unary <code class="computeroutput"><span class="special">!</span></code>)</a>
                    (<code class="computeroutput"><span class="special">!</span><span class="identifier">a</span></code>)
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">a</span><span class="special">:</span>
                    <span class="identifier">A</span> <span class="special">--&gt;</span>
                    <span class="special">!</span><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span></code>
                  </p>
                </td>
</tr>
</tbody>
</table></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="primitive_generators/action.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../quick_reference.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="non_terminals.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
